<template>
    <div v-if="$route.meta.useFrame != undefined && $route.meta.useFrame == true">
        <RouterView></RouterView>
    </div>
    <div v-if="$route.meta.useFrame == undefined || $route.meta.useFrame == false">

  <!--表示接受值 文本插值表达式-->
 <!-- <h1>当前执行的路径为：{{$route.fullPath }}</h1> -->
  <el-container>
      <el-header>
        <el-row>
    <el-col :span="2">
      <img src="./assets/logo.png" alt="" width="200px" height="50px">
    </el-col>
    <el-col :span="20">
     <div style="text-align: center; line-height: 50px;">至本小说</div> 
    </el-col>
    <el-col :span="2">
      <el-dropdown>
    <span class="el-dropdown-link">
      我
      <el-icon class="el-icon--right">
        <arrow-down />
      </el-icon>
    </span>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item @click="goToProfile">个人中心</el-dropdown-item>
        <el-dropdown-item>账户与安全</el-dropdown-item>
        <el-dropdown-item>关于我们</el-dropdown-item>
        
       <el-dropdown-item divided @click="handleLogout">注销</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
    </el-col>
  </el-row></el-header>
      <el-container>
        <el-aside width="200px">
          <Menu></Menu>
        </el-aside>
        <el-main>
          <!--路由的总出口-->
      <RouterView></RouterView>
        </el-main>
      </el-container>
    </el-container>
</div>

</template>
<script setup>
import Menu from './components/Menu.vue';
import { RouterView, useRouter } from 'vue-router';

const router = useRouter();


const goToProfile = () => {
  router.push('/profile')
}
const handleLogout = () => {
  // 清除本地 token
  window.sessionStorage.removeItem('token');
  // 跳转到根目录
  window.location.href = 'http://localhost:5000/'; 
  // 如果登录页是前端路由，可用下面这行代替：
  // router.push('/login');
};
</script>
<style scoped>
.el-header {
    height: 50px;
    padding-left: 0px;
    background-color: #439281;

    .el-dropdown {
        color: #d8dce6;
        font-size: 18px;
        line-height: 50px;
        margin-left: 10px;
    }
}

.el-aside {
    background-color: aquamarine;
}

.el-main {
    padding: 0;
}
</style>
